package ltd.dujiabao.capability.adapter.driven.persistence.rulemng;

import java.util.Collections;
import java.util.List;
import java.util.Map;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import ltd.dujiabao.capability.adapter.properties.LiveUpdateReminder;

/**
 * @author : DuJiabao
 * @Project : ddd-capability
 * @Time : 2024/4/13 10:45
 * @Desc :
 */
@Data
@Configuration
@ConfigurationProperties(prefix = "rule-management")
@LiveUpdateReminder(events = RuleChangedEvent.class)
@Slf4j
public class RuleProperties {

    private Map<String, List<VersionRule>> rules;

    private Support support;

    @Data
    public static class Support {
        private Long lruCacheSize;
    }

    @Data
    public static class VersionRule {
        private String version;
        private List<Expression> and = Collections.emptyList();
        private List<Expression> or = Collections.emptyList();
    }

    @Data
    public static class Expression {
        private String module;
        private String expression;
    }
}
